#ifndef H_LIST
#define H_LIST

#include "debug.h"

class Listable {
};

class ListNode { //Double linked list
   public:
      ListNode*	  prev;
      Listable*		part;
      ListNode* next;

ListNode  ( ListNode* _prev, Listable & _part, ListNode* _next    )  {
   pDebug( this << " ListNode (" << "ListNode* _prev=" << &_prev << "Listable & _part=" << &_part << "ListNode* _next =" << &_next     << ")")
 	 prev = _prev; next = _next; part = &_part;
      }
};

class List {
   private:
      ListNode* list;
      ListNode* iterator;
      ListNode* iteratorB;

   public:
List  (  )  {
   pDebug( this << " List ("   << ")")
 	 list = 0;
	 iterator = 0;
	 iteratorB = 0;
      }

      void add ( Listable * );
void reset  (  )  {
   pDebug( this << " void reset ("   << ")")
 	 iterator = list;
	 if ( iterator != 0 ) {
	    iteratorB = list->next;
	 } else
	    iteratorB = 0;
      }

      virtual Listable * listIter ();

ListNode* getHead (  )  {
   pDebug( this << " ListNode* getHead("   << ")")
 	 return list; 
      }

      Listable* advanceHead ( ListNode** );
      
      Listable** doubleIter ( Listable** ); // iters two iterators
};
#endif
